package edu.ncst.baseweb.controller.webmanage;

import cn.wintersun.basecommon.common.Result;
import edu.ncst.baseweb.dao.web.LabTeam;
import edu.ncst.baseweb.service.intrer.webmanage.LabTeamManageService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/lab/overview/team")
@PreAuthorize("hasAuthority('6')")
public class LabTeamManageController {

    @Autowired
    private LabTeamManageService labTeamManageService;

    @RequestMapping(value = "list",method = RequestMethod.POST)
    public Result<IPage<LabTeam>> list(@RequestBody LabTeam labTeam){

        return  labTeamManageService.list(labTeam);
    }

    @RequestMapping(value = "save",method = RequestMethod.POST)
    public Result<Object> save(@RequestBody LabTeam labTeam){

        return  labTeamManageService.save(labTeam);
    }

    @RequestMapping(value = "delete",method = RequestMethod.POST)
    public Result<Object> delete(@RequestBody String labTeamId){
        try {
            return labTeamManageService.delete(labTeamId);
        } catch (Exception e) {
            return Result.failure(500, e.getMessage());
        }
    }

}
